xenstore: Fix memory leak in command 'xenstore rm'
authorKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Dec 2009 10:39:48 +0000 (10:39 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Mon, 21 Dec 2009 10:39:48 +0000 (10:39 +0000)
When option '-t' is used to do tidy remove, routine xs_directory()
will be called in order to check there are brother directories or not.
The returned pointer should be passed to free() after this check.

Signed-off-by: Yu Zhiguo <yuzg@cn.fujitsu.com>
tools/xenstore/xenstore_client.c

index aaf3014d5372a32c8c310a4604621bf762e0d0b9..50fc3d7646511a7b51abad9626c378c2879f7b61 100644 (file)
@@ -343,8 +343,10 @@ perform(enum mode mode, int optind, int argc, char **argv, struct xs_handle *xsh
                         unsigned int num;
                         char ** list = xs_directory(xsh, xth, p, &num);
 
-                        if (list && num == 0) {
-                            goto again;
+                        if (list) {
+                            free(list);
+                            if (num == 0)
+                                goto again;
                         }
                     }
                 }